<template>
     <div>
         <div @click="fn">点击我</div>
        <div v-for="(item,index) in arr" :key="index" style="margin-top:30px" @click="goDetail(item.id)">
            <span>{{item.title}}</span>
            <img :src="item.url" alt="">
            <span>{{item.price}}</span>
            <span>数量{{item.num}}</span>
            <span>是否选中{{item.checked}}</span>

        </div>
        <div style="height:100px"></div>
     </div>
</template>

<script>
import {mapState,mapActions,mapMutations} from "vuex"
import {debounce} from "../util/dubonce.js"
export default {
    mounted(){
        this.getList()
    },
    methods:{
        ...mapActions(["getList"]),
        goDetail(id){
            this.$router.push(`/detail/${id}`)
        },
        fn:debounce(2000,
             function(){
                 alert(1)
             }
        )
    },
    computed:{
        ...mapState(["arr"])
    },
    

}
</script>

<style>

</style>